﻿using System.ServiceModel;
using Bon.It.Server.Interfaces;

namespace Bon.It.Proxy
{
    public class ServiceProxy
    {

        private static IContract _instance;


        /// <summary>
        /// The instance of <see cref="ClientService.ContractClient"/>.
        /// </summary>
        public static IContract Instance
        {
            get
            {
                if (_instance == null)
                {

                    NetTcpBinding myBinding = new NetTcpBinding("NetTcpBinding_IContract");

                    EndpointAddress myEndpoint = new EndpointAddress("net.tcp://localhost:123/Bonit/Service");


                    ChannelFactory<IContract> factory = new ChannelFactory<IContract>(myBinding, myEndpoint);
                    _instance = factory.CreateChannel();
                }
                return _instance;
            }

        }


    }
}
